<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_device';
	$filename = 'admin/admin_device_list';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('device');
	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,10);
	$data['title']=$title=request('title');
	$data['order']=$order=request('order',false,false,false,'default');
	$data['state']=$state=request('state',false,true,false,0);
	$data['master']=$master=request('master',false,true,0);
	$data['own']=$own=request('own',false,true,false,-1);
	$result = device_fun_get_device_list($data,$page,$pagesize);
	$hover[$data['state']]=' class="hover" ';
	
	require_once $_site->get_handlepath('admin');
	$master_list=admin_fun_list(array('master'=>true),1,10);
	if($master_list){
		foreach ($master_list as $v){
			$master_ary[$v['id']]=$v;
		}
	}
	$order_rtn=array('default'=>'默认排序','time'=>'添加时间','update'=>'编号修改时间')
?>
<script type="text/javascript" charset="utf-8">
	loader.file({
		plugin:['validform/main','dialog/main'],
		skincss:['list']
	})


    //修改记录
	function editinfo(id){
		dialog.iframe({
			title:'绑定详情',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:true,
			min_width:650,
			min_height:400,
			is_center:true,
			is_lock_back:true,
			content:'/admin/devicebind?id='+id,
			name:'choise_project'
		});
	}		
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

			<div class="sos_box">
				<form action="/admin/admin_device_list" id="search" method='get'>
					<span>手机设备编号：</span>
					<input type="text" value="<?php echo $title ;?>" name='title'>
					项目经理:
				    <select name='master'>
					   <option value="">请选择</option>
					      <?php 
					      if($master_list){
					      foreach($master_list as $key=>$val){
                          ?>
                             <option value="<?php echo $val['id']?>" <?php if($val['id']==$master){echo "selected";} ?>><?php echo $val['name']?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>
					归属：<select name="own">
					     <option value="-1">全部</option>
					     <option value="0" <?php if(0==$own){ ?>checked<?php }?>>平台</option>
					     <option value="1" <?php if(1==$own){ ?>checked<?php }?>>项目经理</option>
					    </select>
					排序:
				    <select name='order'>					   
					      <?php 
					      if($order_rtn){
					      foreach($order_rtn as $key=>$val){
                          ?>
                             <option value="<?php echo $key?>" <?php if($key==$order){echo "selected";} ?>><?php echo $val?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>					    
					<input type="hidden" value="<?php echo $data['state'] ;?>" name='state'>

					<input class="button1" type="submit" value="搜索">
				</form>
			</div>
			<div class="power_nav">
				<ul>
					<li <?php echo $hover[0] ;?>>
						<a href="/admin/admin_device_list?state=0&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">全部</a>
					</li>
					<li <?php echo $hover[1] ;?>>
						<a href="/admin/admin_device_list?state=1&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">未绑定</a>
					</li>
					<li<?php echo $hover[2] ;?>>
						<a href="/admin/admin_device_list?state=2&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">绑定</a>
					</li>
				</ul>
			</div>
			<table cellpadding="0" cellspacing="1" border="0" class="table">
				<tr>
					<th width="8%" align="center">序号</th>
					<th width="20%" align="left">手机设备编号</th>
					<th width="10%" align="left">项目经理</th>
					<th width="15%" align="left">设备归属</th>
					<th width="8%" align="center">绑定状态</th>
					<th width="10%" align="center">添加时间</th>
					<th width="10%" align="center">编号修改时间</th>
					<th align="left" style="padding-left: 10px;">操作</th>
				</tr>
				<?php
					$pageOne = (int)$page;
					$pageTwo = (int)$pagesize;
					if($result['rows']){
						$pageNo =$pageOne*$pageTwo - ($pageTwo-1);
						foreach ($result['rows'] as $k=>$v){
							?>
							<tr>
								<td align="center"><?php echo $pageNo++ ;?></td>
								<td align="left"><?php echo $v['no'] ;?></td>
								<td align="left"><?php echo ($v['master']>0 AND $master_ary[$v['master']])?$master_ary[$v['master']]['name']:'--' ;?></td>
								<td align="left"><?php echo 0==$v['own']?'平台':'项目经理' ;?></td>
								<td align="center"><?php echo $v['state']==2?'绑定':"<span style='color:#0b9900;'>未绑定</span>" ;?></td>
								<td align="center"><?php echo date('Y-m-d H:i',$v['time']) ;?></td>
								<td align="center"><?php echo $v['update']?date('Y-m-d H:i',$v['update']):'' ;?></td>
								<td align="left" class="set_text">
								    <a href="/admin/admin_device_add?id=<?php echo $v['id'] ;?>">修改</a>	
								    <?php
                                      if($v['state']==2){
								    ?>	
								    &nbsp;&nbsp;<a href="javascript:;" onclick="editinfo(<?php echo $v['id']?>);">查看绑定</a>				
								    <?php
                                      }
								    ?>		
								</td>
					</tr>
							<?php
						}
					}else{
						?>
						<tr>
							<td colspan="8">暂无数据！</td>
						</tr>
						<?php
					}
				?>
				<tr>
					<td colspan="8">
						<div class="list_more">
							设备总数：<?php echo $result['row_count']?$result['row_count']:0 ;?>
							<?php
								echo page_method($result['row_count'], $page, $result['page_count'], 10, '?'.preg_replace('/(&page=\d*)/','',$_SERVER['QUERY_STRING']), false);
							?>
						</div>
					</td>
				</tr>
			</table
		></div>
	</div>
</body>
</html>


